/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.druid.msq.kernel.controller;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.msq.indexing.destination.DurableStorageMSQDestination;
import org.apache.druid.msq.indexing.destination.MSQDestination;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;
import java.util.Map;

public class ControllerQueryKernelConfigTest
{
  @Test
  public void testBuilder()
  {
    int maxRetainedPartitionSketchBytes = 1;
    int maxConcurrentStages = 2;
    boolean pipeline = false;
    boolean durableStorage = true;
    boolean faultTolerance = true;
    MSQDestination destination = DurableStorageMSQDestination.instance();
    String controllerHost = "controllerHost";
    List<String> workerIds = ImmutableList.of("worker1", "worker2");
    Map<String, Object> workerContextMap = ImmutableMap.of("foo", "bar");

    final ControllerQueryKernelConfig config1 = new ControllerQueryKernelConfig(
        maxRetainedPartitionSketchBytes,
        maxConcurrentStages,
        pipeline,
        durableStorage,
        faultTolerance,
        destination,
        controllerHost,
        workerIds,
        workerContextMap
    );

    final ControllerQueryKernelConfig config2 = ControllerQueryKernelConfig
        .builder()
        .maxRetainedPartitionSketchBytes(maxRetainedPartitionSketchBytes)
        .maxConcurrentStages(maxConcurrentStages)
        .pipeline(pipeline)
        .durableStorage(durableStorage)
        .faultTolerance(faultTolerance)
        .destination(destination)
        .controllerHost(controllerHost)
        .workerIds(workerIds)
        .workerContextMap(workerContextMap)
        .build();

    Assert.assertEquals(config1, config2);
  }

  @Test
  public void testEquals()
  {
    EqualsVerifier.forClass(ControllerQueryKernelConfig.class)
                  .usingGetClass()
                  .verify();
  }
}
